<?php
error_reporting(0);
class ProductInfo{
    function ProductInfo2(){

        //$productInfo=array(

    //);
        $payProducts=$_REQUEST['payProductMap'];
        $payScenarios=$_REQUEST['payScenarioMap'];
        $remitScenario=$_REQUEST['remitScenario'];
        $remitProduct=$_REQUEST['remitProductMap'];
        if($_REQUEST['remitProductMap']==null)
            $remitProduct='';
        $webUrl_web=$_REQUEST['webUrl_web'];
        $icp=$_REQUEST['icp'];
        $webUrl_h5=$_REQUEST['webUrl_h5'];
        $appName=$_REQUEST['appName'];
        $appDownloadUrl=$_REQUEST['appDownloadUrl'];
        $remitScenarioAdd=$_REQUEST['remitScenarioAdd'];
        $merchantType=$_REQUEST['merchantType'];
        $pollCode=$_REQUEST['pollCode'];
        $tradeName=$_REQUEST['tradeName'];

//        foreach ($payProducts as $value) {
//            echo $value.',';
//        }
//        foreach ($payScenarios as $value) {
//            echo $value.',';
//        }
//        foreach ($remitScenario as $value) {
//            echo $value.'--';
//        }
//        foreach ($remitProduct as $value) {
//            echo $value.'--';
//        }

        //支付产品
        $payProductMap = array(
        ONE_KEY_PAY_DEBIT => $_REQUEST['ONE_KEY_PAY_DEBIT'],
		ONE_KEY_PAY_CREDIT => $_REQUEST['ONE_KEY_PAY_CREDIT'],
		B2C_PAY => $_REQUEST['B2C_PAY'],
		B2B_PAY => $_REQUEST['B2B_PAY'],
		WECHAT_ATIVE_SCAN => $_REQUEST['WECHAT_ATIVE_SCAN'],
		ALIPAY => $_REQUEST['ALIPAY'],
		JD_ATIVE_SCAN => $_REQUEST['JD_ATIVE_SCAN'],
		UPOP_ATIVE_SCAN => $_REQUEST['UPOP_ATIVE_SCAN'],
		weChatId => $_REQUEST['weChatId'],
		officialAccAppId => $_REQUEST['officialAccAppId'],
		recommendOfficialAccAppId => $_REQUEST['recommendOfficialAccAppId'],
		officialAccAuthorizeDirectory => $_REQUEST['officialAccAuthorizeDirectory'],
		OFFICIAL_ACCOUNT_PAY => $_REQUEST['OFFICIAL_ACCOUNT_PAY'],
		aliPayPID => $_REQUEST['aliPayPID'],
		ZFB_SHH => $_REQUEST['ZFB_SHH'],
		WECHAT_SCAN => $_REQUEST['WECHAT_SCAN'],
		ALIPAY_SCAN => $_REQUEST['ALIPAY_SCAN'],
		JD_PASSIVE_SCAN => $_REQUEST['JD_PASSIVE_SCAN'],
		UPOP_PASSIVE_SCAN => $_REQUEST['UPOP_PASSIVE_SCAN'],
		WECHAT_H5_LOW => $_REQUEST['WECHAT_H5_LOW'],
		WECHAT_H5 => $_REQUEST['WECHAT_H5'],
		ALIPAY_H5 => $_REQUEST['ALIPAY_H5'],
		WECHAT_SDK => $_REQUEST['WECHAT_SDK'],
		ALIPAY_SDK => $_REQUEST['ALIPAY_SDK'],
		JQ_BK => $_REQUEST['JQ_BK'],
		ZF_BK_JJK => $_REQUEST['ZF_BK_JJK'],
		ZF_BK_DJK => $_REQUEST['ZF_BK_DJK'],
		ACCOUNT_PAY => $_REQUEST['ACCOUNT_PAY'],
        //新增
        POS_PAY_CREDIT=>$_REQUEST['POS_PAY_CREDIT'],
        POS_PAY_DEBIT=>$_REQUEST['POS_PAY_DEBIT'],
        cappingValue=>$_REQUEST['cappingValue']);
		$json = "";

		//支付场景
		$payScenarioMap = array(
		webUrl_web=>$webUrl_web,
		icp=>$icp,
		webUrl_h5=>$webUrl_h5,
		appName=>$appName,
		appDownloadUrl=>$appDownloadUrl,
        merchantType=> $merchantType,
		pollCode=> $pollCode,
		tradeName=>$tradeName);

		//出款产品
        $remitProductMap = array(
		RECHARGE_REMIT => $_REQUEST['RECHARGE_REMIT'],
		REMIT_BANK_NORMAL => $_REQUEST['REMIT_BANK_NORMAL'],
		REMIT_BANK_REALTIME => $_REQUEST['REMIT_BANK_REALTIME'],
		REMIT_ALL_DAY => $_REQUEST['REMIT_ALL_DAY'],
		REMIT_TOPSPEED => $_REQUEST['REMIT_TOPSPEED'],
		REMIT_ACCOUNT_REMIT => $_REQUEST['REMIT_ACCOUNT_REMIT'],
		REMIT_RJT_NORMAL => $_REQUEST['REMIT_RJT_NORMAL'],
		REMIT_RJT_EXPRESS_WORKDAY => $_REQUEST['REMIT_RJT_EXPRESS_WORKDAY'],
		REMIT_RJT_EXPRESS_WEEKDAY => $_REQUEST['REMIT_RJT_EXPRESS_WEEKDAY'],
		firstPartyPercentage => $_REQUEST['firstPartyPercentage']);

        //提现产品
//		$withdrawMap = array(
//		WITHDRAW_D0=>$_REQUEST['WITHDRAW_D0'],
//		WITHDRAW_D1=>$_REQUEST['WITHDRAW_D1'],
//		WITHDRAW_WORKDAY=>$_REQUEST['WITHDRAW_WORKDAY'],
//		WITHDRAW_WEEKDAY=>$_REQUEST['WITHDRAW_WEEKDAY'],
//		rateType=>$_REQUEST['rateType'],
//		fixedRate=>$_REQUEST['fixedRate'],
//		percentRate=>$_REQUEST['percentRate']);

        $jsonProduct = ProductInfo::createProduct($payProducts, $payProductMap);
		$jsonScenario = ProductInfo::createScenario($payScenarios, $payScenarioMap);
		$jsonProductR = ProductInfo::createRemitProduct($remitProduct, $remitProductMap, $remitScenario, $remitScenarioAdd);

        $WITHDRAWMAP=$_REQUEST['WITHDRAWMAP'];
        $D0withdrawBankName=$_REQUEST['D0withdrawBankName'];
        $D1withdrawBankName=$_REQUEST['D1withdrawBankName'];

        $withDrawjson = ProductInfo::CreateWithDrawJson($WITHDRAWMAP,$D0withdrawBankName,$D1withdrawBankName);


//echo $jsonProduct;
//		echo '-----------';
//		echo $jsonScenario;
//        echo '-----------';
//		echo $jsonProductR;
//        echo '-----------';

		$json = '{'.$jsonProduct.','.$jsonScenario;
		if ($jsonProductR != "") {
            $json .= ",".$jsonProductR;
        }
        if($withDrawjson !=""){
            $json .= ","."\"withdrawProductMap\":".json_encode($withDrawjson);
        }
		$json .= '}';
		echo $json;

    }
    function createProduct( $payProducts, $payProductMap){
        $json = '"payProductMap":{';
        foreach ($payProducts as $product) {
            if ('ONEKEY'==$product) {
                $json.=ProductInfo::createONEKEY($payProductMap);
            }
            if ('NETBANK'==$product) {
                $json.=ProductInfo::createNETBANK($payProductMap);
            }
            if ('SCANPAY'==$product) {
                $json.=ProductInfo::createSCANPAY($payProductMap);
            }
            if ('WECHATOPEN'==$product) {
                $json.=ProductInfo::createWECHATOPEN($payProductMap);
            }
            if ('ZFBSHH'==$product) {
                $json.=ProductInfo::createZFBSHH($payProductMap);
            }
            if ('MSCANPAY'==$product) {
                $json.=ProductInfo::createMSCANPAY($payProductMap);
            }
            if ('EWALLETH5'==$product) {
                $json.=ProductInfo::createEWALLETH5($payProductMap);
            }
            if ('EWALLET'==$product) {
                $json.=ProductInfo::createEWALLET($payProductMap);
            }
            if ('BK'==$product) {
                $json.=ProductInfo::createBK($payProductMap);
            }
            if ('ACCOUNT'==$product) {
                $json.=ProductInfo::createACCOUNT($payProductMap);
            }
            if('POSPAY'==$product){
                $json.=ProductInfo::createPos($payProductMap);
            }
            $json.=",";
        }
		$jsonProduct = substr($json, 0,strlen($json)-1)."}";
		return $jsonProduct;
    }
    //C:\Users\dong_tt\Desktop\productInfo
    /**
     * 支付场景
     * @param payScenarios
     * @param payScenarioMap
     * @return
     */
    function createScenario($payScenarios, $payScenarioMap){
        $json = '';
        $json.='"payScenarioMap":{';
        foreach ($payScenarios as $scenario) {
            $json.='"'.$scenario.'":{';
            if('WEB_ACCESS' == $scenario){
                $webUrl = $payScenarioMap['webUrl_web'];
                $icp = $payScenarioMap['icp'];
            $json.='"webUrl":"'.$webUrl.'",';
            $json.='"icp":"'.$icp.'"';
        }
        if('H5_ACCESS' == $scenario){
            $webUrl = $payScenarioMap['webUrl_h5'];
                        $json.='"webUrl":"'.$webUrl.'"';
                    }
        if('APP_ACCESS'==$scenario){
            $appName = $payScenarioMap['appName'];
                        $json.='"appName":"'.$appName.'",';
                        $appDownloadUrl = $payScenarioMap['appDownloadUrl'];
                        $json.='"appDownloadUrl":"'.$appDownloadUrl.'"';
                    }
         if("OFFLINE_ACCESS"==$scenario){
            $merchantType=$payScenarioMap['merchantType'];
            $string="";
            foreach ($merchantType as $value)
            {
                $string.=$value.",";
            }
           $merchantType=substr($string,0,strlen($string)-1);
          //  echo $merchantType;
                        $json.='"merchantType":"'.$merchantType.'",';
                        $pollCode=$payScenarioMap['pollCode'];
                        $json.='"pollCode":"'.$pollCode.'",';
                        $tradeName=$payScenarioMap['tradeName'];
                        $json.='"tradeName":"'.$tradeName.'"';
                    }
        $json.='},';
        }
        return substr($json, 0,strlen($json)-1).'}';
	}
    /**
     * 一键支付
     * @param payProductMap
     * @return
     */
    function createONEKEY($payProductMap){
        $json = '';
        $ONE_KEY_PAY_DEBIT = $payProductMap['ONE_KEY_PAY_DEBIT'];
        $ONE_KEY_PAY_CREDIT = $payProductMap['ONE_KEY_PAY_CREDIT'];
        if(!""==$ONE_KEY_PAY_DEBIT && $ONE_KEY_PAY_DEBIT != null)
            $json.='"ONE_KEY_PAY_DEBIT":{"dsPayBankMap":{"BANK_PAY_WAP":{"rateType":"PERCENTAGE","rate":"'.$ONE_KEY_PAY_DEBIT.'"}}},';
        if(!""==$ONE_KEY_PAY_CREDIT && $ONE_KEY_PAY_CREDIT != null)
            $json.='"ONE_KEY_PAY_CREDIT":{"dsPayBankMap":{"BANK_PAY_WAP":{"rateType":"PERCENTAGE","rate":"'.$ONE_KEY_PAY_CREDIT.'"}}}}';
        if(""==$json) return "";
        return substr($json,0, strlen($json)-1);
    }

    /**
     * 网银支付
     * @param payProductMap
     * @return
     */
        function createNETBANK($payProductMap){
                $json = '';
                $B2C_PAY = $payProductMap['B2C_PAY'];
                $B2B_PAY = $payProductMap['B2B_PAY'];
                if(!""==$B2C_PAY && $B2C_PAY != null)
                    $json.='"B2C_PAY":{"dsPayBankMap":{"NET_BANK":{"rateType":"PERCENTAGE","rate":"'.$B2C_PAY.'"}}},';
                if(!""==$B2B_PAY && $B2B_PAY != null)
                    $json.='"B2B_PAY":{"dsPayBankMap":{"NET_BANK":{"rateType":"ONEPAY","rate":"'.$B2B_PAY.'"}}},';
                if(strlen($json)<1) return "";
                return substr($json,0, strlen($json)-1);
            }

        /**
         * 用户扫码
         * @param payProductMap
         * @return
         */
        function createSCANPAY($payProductMap){
            $json = '';
            $WECHAT_ATIVE_SCAN = $payProductMap['WECHAT_ATIVE_SCAN'];
            $ALIPAY = $payProductMap['ALIPAY'];
            $JD_ATIVE_SCAN = $payProductMap['JD_ATIVE_SCAN'];
            $UPOP_ATIVE_SCAN = $payProductMap['UPOP_ATIVE_SCAN'];
            $json.='"USER_SCAN_PAY":{"dsPayBankMap":{';

            if($WECHAT_ATIVE_SCAN != "" && $WECHAT_ATIVE_SCAN != null)
                $json.='"WECHAT_ATIVE_SCAN":{"rateType":"PERCENTAGE","rate":"'.$WECHAT_ATIVE_SCAN.'"},';
            if($ALIPAY != "" && $ALIPAY != null)
                $json.='"ALIPAY":{"rateType":"PERCENTAGE","rate":"'.$ALIPAY.'"},';
            if($JD_ATIVE_SCAN != "" && $JD_ATIVE_SCAN != null)
                $json.='"JD_ATIVE_SCAN":{"rateType":"PERCENTAGE","rate":"'.$JD_ATIVE_SCAN.'"},';
            if($UPOP_ATIVE_SCAN != "" && $UPOP_ATIVE_SCAN != null)
                $json.='"UPOP_ATIVE_SCAN":{"rateType":"PERCENTAGE","rate":"'.$UPOP_ATIVE_SCAN.'"},';
            if(strlen($json)<1) return "";
            return substr($json,0, strlen($json)-1)."}}";
        }

        /**
         * 公众号支付
         * @param payProductMap
         * @return
         */
        function createWECHATOPEN($payProductMap){
            $json = '';
            $OFFICIAL_ACCOUNT_PAY = $payProductMap['OFFICIAL_ACCOUNT_PAY'];
            $weChatId = $payProductMap['weChatId'];
            $officialAccAppId = $payProductMap['officialAccAppId'];
            $recommendOfficialAccAppId = $payProductMap['recommendOfficialAccAppId'];
            $officialAccAuthorizeDirectory = $payProductMap['officialAccAuthorizeDirectory'];
            $json.='"OFFICIAL_ACCOUNT_PAY":{"dsPayBankMap":{"WECHAT_OPENID":{"rateType":"PERCENTAGE","rate":"'.$OFFICIAL_ACCOUNT_PAY.'"}},';
            $json.='"weChatId":"'.$weChatId.'",';
            $json.='"officialAccAppId":"'.$officialAccAppId.'",';
            $json.='"recommendOfficialAccAppId":"'.$recommendOfficialAccAppId.'",';
            $json.='"officialAccAuthorizeDirectory":"'.$officialAccAuthorizeDirectory.'"}';

            return $json;
        }

        /**
         * 生活号支付
         * @param payProductMap
         * @return
         */
        function createZFBSHH($payProductMap){
            $json = '';
            $ZFB_SHH = $payProductMap['ZFB_SHH'];
            $aliPayPID = $payProductMap['aliPayPID'];
            $json.='"ZFB_SHH":{"dsPayBankMap":{"ZFB_SHH":{"rateType":"PERCENTAGE","rate":"'.$ZFB_SHH.'"}},';
            $json.='"aliPayPID":"'.$aliPayPID.'"}';
            return $json;
        }

        /**
         * 商家扫码
         * @param payProductMap
         * @return
         */
        function createMSCANPAY($payProductMap){

    $json = '';
            $WECHAT_SCAN = $payProductMap['WECHAT_SCAN'];
            $ALIPAY_SCAN = $payProductMap['ALIPAY_SCAN'];
            $JD_PASSIVE_SCAN = $payProductMap['JD_PASSIVE_SCAN'];
            $UPOP_PASSIVE_SCAN = $payProductMap['UPOP_PASSIVE_SCAN'];
            $json.='"MERCHANT_SCAN_PAY":{"dsPayBankMap":{';
            if($WECHAT_SCAN != "" && $WECHAT_SCAN != null)
                $json.='"WECHAT_SCAN":{"rateType":"PERCENTAGE","rate":"'.$WECHAT_SCAN.'"},';
            if($ALIPAY_SCAN != "" && $ALIPAY_SCAN != null)
                $json.='"ALIPAY_SCAN":{"rateType":"PERCENTAGE","rate":"'.$ALIPAY_SCAN.'"},';
            if($JD_PASSIVE_SCAN != "" && $JD_PASSIVE_SCAN != null)
                $json.='"JD_PASSIVE_SCAN":{"rateType":"PERCENTAGE","rate":"'.$JD_PASSIVE_SCAN.'"},';
            if($UPOP_PASSIVE_SCAN != "" && $UPOP_PASSIVE_SCAN != null)
                $json.='"UPOP_PASSIVE_SCAN":{"rateType":"PERCENTAGE","rate":"'.$UPOP_PASSIVE_SCAN.'"},';
            if(strlen($json)<1) return "";
            return substr($json,0, strlen($json)-1)."}}";
        }

        /**
         * 钱包H5支付
         * @param payProductMap
         * @return
         */
        function createEWALLETH5($payProductMap){
            $json = '';
            $WECHAT_H5_LOW = $payProductMap['WECHAT_H5_LOW'];
            $WECHAT_H5 = $payProductMap['WECHAT_H5'];
            $ALIPAY_H5 = $payProductMap['ALIPAY_H5'];
            $json.='"EWALLETH5":{"dsPayBankMap":{';
            if($WECHAT_H5_LOW != "" && $WECHAT_H5_LOW != null)
                $json.='"WECHAT_H5_LOW":{"rateType":"PERCENTAGE","rate":"'.$WECHAT_H5_LOW.'"},';
            if($WECHAT_H5 != "" && $WECHAT_H5 != null)
                $json.='"WECHAT_H5":{"rateType":"PERCENTAGE","rate":"'.$WECHAT_H5.'"},';
            if($ALIPAY_H5 != "" && $ALIPAY_H5 != null)
                $json.='"ALIPAY_H5":{"rateType":"PERCENTAGE","rate":"'.$ALIPAY_H5.'"},';
            if(strlen($json)<1) return "";
            return substr($json,0, strlen($json)-1)."}}";
        }

        /**
         * 钱包SDK支付
         * @param payProductMap
         * @return
         */
        function createEWALLET($payProductMap){
    $json = '';
            $WECHAT_SDK = $payProductMap['WECHAT_SDK'];
            $ALIPAY_SDK = $payProductMap['ALIPAY_SDK'];
            $json.='"EWALLET":{"dsPayBankMap":{';
            if($WECHAT_SDK != "" && $WECHAT_SDK != null)
                $json.='"WECHAT_SDK":{"rateType":"PERCENTAGE","rate":"'.$WECHAT_SDK.'"},';
            if($ALIPAY_SDK != "")
                $json.='"ALIPAY_SDK":{"rateType":"PERCENTAGE","rate":"'.$ALIPAY_SDK.'"},';
            if(strlen($json)<1) return "";
            return substr($json,0, strlen($json)-1)."}}";
        }

        /**
         * 绑卡支付
         * @param payProductMap
         * @return
         */
        function createBK($payProductMap){
    $json = '';
            $JQ_BK = $payProductMap['JQ_BK'];
            $ZF_BK_JJK = $payProductMap['ZF_BK_JJK'];
            $ZF_BK_DJK = $payProductMap['ZF_BK_DJK'];

            if($JQ_BK != "" && $JQ_BK != null)
                $json.='"JQ_BK":{"dsPayBankMap":{"JQ_BK":{"rateType":"ONEPAY","rate":"'.$JQ_BK.'"}}},';
            if($ZF_BK_JJK != "" && $ZF_BK_JJK != null)
                $json.='"ZF_BK_JJK":{"dsPayBankMap":{"ZF_BK":{"rateType":"PERCENTAGE","rate":"'.$ZF_BK_JJK.'"}}},';
            if($ZF_BK_DJK != "" && $ZF_BK_DJK != null)
                $json.='"ZF_BK_DJK":{"dsPayBankMap":{"ZF_BK":{"rateType":"PERCENTAGE","rate":"'.$ZF_BK_DJK.'"}}},';
            if(strlen($json)<1) return "";
            return substr($json,0, strlen($json)-1)."}}";
        }

        /**
         * 账户企业支付
         * @param payProductMap
         * @return
         */
        function createACCOUNT($payProductMap){
    $json = '';
            $ACCOUNT_PAY = $payProductMap['ACCOUNT_PAY'];
            if($ACCOUNT_PAY != "" && $ACCOUNT_PAY != null)
                $json.='"ACCOUNT_PAY":{"dsPayBankMap":{"ACCOUNT_PAY":{"rateType":"PERCENTAGE","rate":"'.$ACCOUNT_PAY.'"}}},';
            if(strlen($json)<1) return "";
            return substr($json,0, strlen($json)-1);
        }
        //POS
       function createPos($payProductMap){
           $json='';
           $POS_PAY_DEBIT=$payProductMap['POS_PAY_DEBIT'];
           $POS_PAY_CREDIT=$payProductMap['POS_PAY_CREDIT'];
           $cappingValue=$payProductMap['cappingValue'];
           if($POS_PAY_DEBIT !="" && $POS_PAY_DEBIT!=null)
           {
               //$json.='"POS_PAY_DEBIT":{"dsPayBankMap":{"POS_PAY":{"rateType":"PERCENTAGE","rate":"'.$POS_PAY_DEBIT.""}},"cappingValue":"'.$cappingValue.""},'
                $json.='"POS_PAY_DEBIT":{"dsPayBankMap":{"POS_PAY":{"rateType":"PERCENTAGE","rate":"'.$POS_PAY_DEBIT.'"}},"cappingValue":"'.$cappingValue.'"},';
           }
           if($POS_PAY_CREDIT !=""&& $POS_PAY_CREDIT!=null)
           {
               $json.='"POS_PAY_CREDIT":{"dsPayBankMap":{"POS_PAY":{"rateType":"PERCENTAGE","rate":"'.$POS_PAY_CREDIT.'"}}},';
           }
           if($json=="")return "";
           return substr($json,0,strlen($json)-1);
       }

        /**
         * 出款产品
         * @param remitProduct
         * @param payProductMap
         * @param remitScenario
         * @param remitScenarioAdd
         * @return
         */
        function createRemitProduct($remitProduct,$payProductMap,$remitScenario, $remitScenarioAdd){
            $json = '';
            if ($remitProduct == null) {
                return "";
            }
            $json.='"remitProductMap":{';

            foreach ($remitProduct as $product) {
                if('RECHARGE'==$product){
                    $json.=ProductInfo::createRECHARGE($payProductMap);
                }
                if('REMIT_BANK'==$product){
                    $json.=ProductInfo::createREMIT_BANK($payProductMap, $remitScenario, $remitScenarioAdd);
                }
                if('REMIT_ACCOUNT'==$product){
                    $json.=ProductInfo::createREMIT_ACCOUNT($payProductMap);
                }
                if('REMIT_RJT'==$product){
                    $json.=ProductInfo::createREMIT_RJT($payProductMap);
                }
                $json.=',';
            }
            return substr($json,0, strlen($json)-1)."}";
        }

        //充值
        function createRECHARGE($payProductMap) {
            $json = '';
            $RECHARGE = $payProductMap['RECHARGE_REMIT'];
            $json.='"RECHARGE":{"dsRemitBankMap":{"RECHARGE":{"rateType":"ONEPAY","rate":"'.$RECHARGE.'"}}}';
            return $json;
        }

        //付款到银行
        function createREMIT_BANK($payProductMap, $remitScenario, $remitScenarioAdd) {
            $json = '';
            $REMIT_BANK_NORMAL = $payProductMap['REMIT_BANK_NORMAL'];
            $REMIT_BANK_REALTIME = $payProductMap['REMIT_BANK_REALTIME'];
            $REMIT_ALL_DAY = $payProductMap['REMIT_ALL_DAY'];
            $REMIT_TOPSPEED = $payProductMap['REMIT_TOPSPEED'];

            $json.='"REMIT_BANK":{"dsRemitBankMap":{';
            if($REMIT_BANK_NORMAL != "" && $REMIT_BANK_NORMAL != null)
                $json.='"REMIT_BANK_NORMAL":{"rateType":"ONEPAY","rate":"'.$REMIT_BANK_NORMAL.'"},';
            if($REMIT_BANK_REALTIME != "" && $REMIT_BANK_REALTIME != null)
                $json.='"REMIT_BANK_REALTIME":{"rateType":"ONEPAY","rate":"'.$REMIT_BANK_REALTIME.'"},';
            if($REMIT_ALL_DAY != "" && $REMIT_ALL_DAY != null)
                $json.='"REMIT_ALL_DAY":{"rateType":"ONEPAY","rate":"'.$REMIT_ALL_DAY.'"},';
            if($REMIT_TOPSPEED != "" && $REMIT_TOPSPEED != null)
                $json.='"REMIT_TOPSPEED":{"rateType":"ONEPAY","rate":"'.$REMIT_TOPSPEED.'"},';
            $flag = false;
            $json=substr($json,0, strlen($json)-1);
            $json.='},"remitScenario":"';
            foreach($remitScenario as $scenario){
                if('OTHERS'==$scenario)
                    $flag = true;
                $json.=$scenario.',';
            }
            $json=substr($json,0, strlen($json)-1).'"';
            if ($flag)
                $json.=',"remitScenarioAdd":"'.$remitScenarioAdd.'"';
            return $json.='}';
        }


        //付款到账户
        function createREMIT_ACCOUNT($payProductMap) {
            $json = '';
            $REMIT_ACCOUNT_REMIT = $payProductMap['REMIT_ACCOUNT_REMIT'];
            $json.='"REMIT_ACCOUNT":{"dsRemitBankMap":{"REMIT_ACCOUNT":{"rateType":"ONEPAY","rate":"'.$REMIT_ACCOUNT_REMIT.'"}}}';
            return $json;
        }

        //日结通
        function createREMIT_RJT($payProductMap) {
            $json = '';
            $REMIT_RJT_EXPRESS_WORKDAY = $payProductMap['REMIT_RJT_EXPRESS_WORKDAY'];
            $REMIT_RJT_EXPRESS_WEEKDAY = $payProductMap['REMIT_RJT_EXPRESS_WEEKDAY'];
            $firstPartyPercentage = $payProductMap['firstPartyPercentage'];
            $json.='"REMIT_RJT":{"dsRemitBankMap":{';
            if($REMIT_RJT_EXPRESS_WORKDAY != "" && $REMIT_RJT_EXPRESS_WORKDAY != null)
                $json.='"REMIT_RJT_EXPRESS_WORKDAY":{"rateType":"PERCENTAGE","rate":"'.$REMIT_RJT_EXPRESS_WORKDAY.'"},';
            if($REMIT_RJT_EXPRESS_WEEKDAY != "" && $REMIT_RJT_EXPRESS_WEEKDAY != null)
                $json.='"REMIT_RJT_EXPRESS_WEEKDAY":{"rateType":"PERCENTAGE","rate":"'.$REMIT_RJT_EXPRESS_WEEKDAY.'"}},';
            if($firstPartyPercentage != "" && $firstPartyPercentage != null)
                $json.='"firstPartyPercentage":"'.$firstPartyPercentage.'",';
            return substr($json,0, strlen($json)-1)."}";
        }


    function CreateWithDrawJson($WITHDRAWMAP, $d0withdrawBankName, $d1withdrawBankName) {
        if (count($WITHDRAWMAP) <= 0) {
            return "";
        }

        $d0Map = "";
        if ($d0withdrawBankName != null && count($d0withdrawBankName) > 0) {
            foreach ($d0withdrawBankName as $d0BankName) {
                if ($d0BankName=="WITHDRAW_WORKDAY") {
                    $d0Map_1 = ProductInfo::createOne("MIXED", $_REQUEST["D0fixedRate_work"], $_REQUEST["D0percentRate_work"]);
                    $d0Map = array(WITHDRAW_WORKDAY=>$d0Map_1);
                }

                if ($d0BankName=="WITHDRAW_WEEKDAY") {
                    $d0Map_2 = ProductInfo::createOne("MIXED", $_REQUEST["D0fixedRate_week"], $_REQUEST["D0percentRate_week"]);
                    if($d0Map=="")
                        $d0Map = array(WITHDRAW_WEEKDAY=>$d0Map_2);
                    else
                        $d0Map = array_merge($d0Map,array(WITHDRAW_WEEKDAY=>$d0Map_2));
                }
            }
        }


        $d1Map = "";
        if ($d1withdrawBankName != null && count($d1withdrawBankName) > 0) {
            foreach ($d1withdrawBankName as $d1BankName) {
                if ($d1BankName == "WITHDRAW_WORKDAY") {
                    $d1Map_1 = ProductInfo::createOne("MIXED", $_REQUEST["D1fixedRate_work"], $_REQUEST["D1percentRate_work"]);
//                    $d1Map = array(WITHDRAW_WORKDAY=>$map);
                    $d1Map = array(WITHDRAW_WORKDAY=>$d1Map_1);
                }

                if ($d1BankName == "WITHDRAW_WEEKDAY") {
                    $d1Map_2 = ProductInfo::createOne("MIXED", $_REQUEST["D1fixedRate_week"], $_REQUEST["D1percentRate_week"]);
//                    $d1Map_2 = array(WITHDRAW_WEEKDAY=>$map);
                    if($d1Map=="")
                        $d1Map = array(WITHDRAW_WEEKDAY=>$d1Map_2);
                    else
                        $d1Map = array_merge($d1Map,array(WITHDRAW_WEEKDAY=>$d1Map_2));
                }
            }
        }

        $d0ParentMap = array(dsWithdrawBankMap=>$d0Map);

        $d1ParentMap = array(dsWithdrawBankMap=>$d1Map);


        $d0PParentMap = array(WITHDRAW_D0=>$d0ParentMap);

        $d1PParentMap = array(WITHDRAW_D1=>$d1ParentMap);


        $map = array(
            WITHDRAW_D0=>$d0ParentMap,
            WITHDRAW_D1=>$d1ParentMap);

        return $map;
    }
    function createOne($rateType, $fixedRate, $percentRate) {
        $map = array(rateType=>$rateType,
            fixedRate=>$fixedRate,
            percentRate=>$percentRate);

        return $map;
    }

}
ProductInfo::ProductInfo2();